
import pymysql
from faker import Faker

faker = Faker(locale='zh_CN')

i=0

while i < 100:

    conn = pymysql.connections.Connection(host="127.0.0.1", port=3306, user="root", passwd="root",db="shop")
    sql = "insert into user(username,password,email,sex,phone,addr,name,state) values(%s,%s,%s,%s,%s,%s,%s,%s)"

    cursor = conn.cursor()

    result = cursor.execute(sql,(faker.name(),faker.password(),faker.email(),"男",faker.phone_number(),faker.address(),faker.name(),1))
    i+=1


    conn.commit()

    # 关闭连接
    cursor.close()
    conn.close()